package com.mayikt;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @ClassName Test20
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test20 {
    private static Lock lock = new ReentrantLock();

    public synchronized static void main(String[] args) {
        a();

    }

    public static void a() {
        lock.lock();
        ;
        System.out.println("我是A");
        b();
        lock.unlock();
    }

    public static void b() {
        lock.lock();
        ;
        System.out.println("我是B");
        lock.unlock();
    }
}
